package cn.thinkluck.pattern.strategy;

import lombok.extern.slf4j.Slf4j;

/**
 * 策略模式
 * 根据不同的加减法策略，调用计算器，执行计算
 * @Author liutao
 * @DateTime 2024/8/1 下午10:20
 */
@Slf4j
public class Main {
    public static void main(String[] args) {
        //执行计算器的加法运算
        Calculator addOperationImpl = new Calculator(new AddOperationImpl());
        log.info("4 + 5 = {}", addOperationImpl.calculate(4, 5));
        //执行计算器的减法运算
        Calculator subOperationImpl = new Calculator(new SubOperationImpl());
        log.info("4 - 5 = {}", subOperationImpl.calculate(4, 5));
    }
}
